package com.ssh.dao.impl;

import com.ssh.dao.BzdmDao;
import com.ssh.dao.DepartDao;
import com.ssh.entity.Bzdm;
import com.ssh.entity.Depart;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public class DepartDaoImpl implements DepartDao {
    @Autowired
    private SessionFactory sessionFactory;
    public void setSessionFactory(SessionFactory sessionFactory){
        this.sessionFactory = sessionFactory;
    }

    @Override
    public List<Depart> getAllDepart() {
        String hql = "from Depart";
        Query query = sessionFactory.getCurrentSession().createQuery(hql);
        return query.list();

    }
}
